package parser.domain;

public class TerminalSymbol implements Symbol {
	String symbol;

	public TerminalSymbol(String value) {
		if (value.equals("eps") || (value.toLowerCase().equals(value) && value.length() == 1)) {
			symbol = value;
		} else {
			throw new IllegalArgumentException(
					"NonTerminal symbols must be equal to \"eps\" or lowercase and have length eaxctly 1");
		}
	}
	
	@Override
	public String toString() {
		return  symbol ;
	}

	@Override
	public String getSymbol() {
		return symbol;
	}
	
	@Override
	public int hashCode(){
		return symbol.hashCode();
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TerminalSymbol other = (TerminalSymbol) obj;
		if (symbol == null) {
			if (other.symbol != null)
				return false;
		} else if (!symbol.equals(other.symbol))
			return false;
		return true;
	}
}
